/*
 * @lc app=leetcode.cn id=46 lang=golang
 *
 * [46] 全排列
 */

// @lc code=start
func permute(nums []int) (ans [][]int) {
	if len(nums) == 1 {
		return append(ans, nums)
	}

	for i := 0; i < len(nums); i++ {
		temp := make([]int, len(nums))
		copy(temp, nums)
		for _, v := range permute(append(temp[:i], temp[i+1:]...)) {
			ans = append(ans, append([]int{nums[i]}, v...))
		}
	}
	return
}

// @lc code=end

